<template>
  <div class="notification is-info" id="notice" v-show="!!message">
    <button class="delete" @click="close"></button>
    {{ message }}
  </div>
</template>

<script>
import bus from "../bus";
export default {
  data() {
    return {
      message: ""
    };
  },
  watch: {
    message(message) {
      if (message !== "") {
        setTimeout(this.close, 2000);
      }
    }
  },
  created() {
    bus.$on("notice", msg => {
      this.message = msg;
    });
  },
  methods: {
    close() {
      this.message = "";
    }
  }
};
</script>
